#include <iostream>
#include <vector>
#include <ctime>
using namespace std;
#define ROW 10
#define COL 10

int main()
{
    vector<int> dx = {-1, 1, 0, 0};
    vector<int> dy = {0, 0, -1, 1};
    srand((unsigned int)time(nullptr));
    vector<vector<char>> matrix(ROW, vector<char>(COL, '.'));
    auto isValid = [&matrix](int x, int y)->bool{
        if(x >= 0 && x < ROW && y >= 0 && y < COL && matrix[x][y] == '.')
            return true;
        else
            return false;
    };

    int x = 0, y = 0;
    matrix[0][0] = 'A';
    bool flag = true;
    for(char ch = 'B'; ch <= 'Z' && flag; ch++)
    {
        flag = false;
        vector<bool> able(4, false);
        for(int i = 0; i < 4; i++)
        {
            if(isValid(x + dx[i], y + dy[i]))
            {
                able[i] = true;
                flag = true;
            }
        }
        while(flag)
        {
            int choice = rand() % 4;
            if(able[choice])
            {
                x += dx[choice];
                y += dy[choice];
                matrix[x][y] = ch;
                break;
            }
        }
    }
    for(int i = 0; i < ROW; i++)
    {
        for(int j = 0; j < COL; j++)
            cout << matrix[i][j] << " ";
        cout << endl;
    }
    return 0;
}